﻿#region NeoPatterns
// 
// NeoPatterns framework is released under LGPLv3 license.
// See http://www.opensource.org/licenses/lgpl-3.0.html for more details.
// 
// Please visit http://neopatterns.wikidot.com for more information about NeoPatterns
// 
// Copyright (c) Pascal Craponne 2008
// 
#endregion

using NeoPatterns.Core.Registry;

namespace NeoPatterns.Utility
{
    /// <summary>
    /// Extensions to IObjectRegistry, to allow running object definitions
    /// </summary>
    public static class ObjectRegistryExtension
    {
        public static ObjectDefinitionTransport<T> Register<T>(this IObjectRegistry objectRegistry)
        {
            return new ObjectDefinitionTransport<T>(objectRegistry);
        }
        /// <summary>
        /// Initializes object with dependencies, generic version
        /// </summary>
        /// <typeparam name="TObject"></typeparam>
        /// <param name="objectRegistry"></param>
        /// <param name="instance"></param>
        public static void Initialize<TObject>(this IObjectRegistry objectRegistry, TObject instance)
        {
            objectRegistry.Initialize(instance, typeof(TObject));
        }
    }
}
